import axios from "axios";
import{message} from "antd";

const authRequest = axios.create({
    baseURL:"/auth"
})

// 请求拦截
authRequest.interceptors.request.use((config:any)=>{
    if(localStorage.getItem("token")){
        config.headers.token = localStorage.getItem("token");
    }
    return config;
})

authRequest.interceptors.response.use(({data})=>{
    if(data.code === 200){
        return data;
    }
    message.error(data.message);
    return new Promise(()=>{});
})
export default authRequest;